﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Cloud.Model;
using Cloud.BLL;
using System.Configuration;

public partial class Three_Managerment_Problem_save_List_ybl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                bind();
                bind2();
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
    protected void AspNetPager_PageChanged(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind();
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
    protected void AspNetPager2_PageChanged(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind2();
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }


    public void bind()
    {
        try
        {

            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select * from problem where current_ld=0 and handle_type = 2 order by id desc", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            AspNetPager1.PageSize = 10;//设置分页大小 
            AspNetPager1.RecordCount = ProblemManager.Bm0_ybl_all().Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "problem");//固定不变的 
            repeater.DataSource = ds.Tables["problem"];
            repeater.DataBind();
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    public void bind2()
    {
        try
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select * from problem where handle_type = 2 order by id desc", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            AspNetPager2.PageSize = 10;//设置分页大小 
            AspNetPager2.RecordCount = ProblemManager.Ybl_all().Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager2.PageSize * (AspNetPager2.CurrentPageIndex - 1), AspNetPager2.PageSize, "problem");//固定不变的 
            repeater2.DataSource = ds.Tables["problem"];
            repeater2.DataBind();

        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv["source_id"]); //获取填充子类的id 
                IList<Sources> sou = new List<Sources>();
                sou.Add(SourcesManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //事件状态
    public string sjzt(int i)
    {
        try
        {

            String zts = "";
            if (i == 0)
            {
                zts = "待办理";
            }
            else if (i == 1)
            {
                zts = "办理中";
            }
            else if (i == 2)
            {
                zts = "已办理";
            }
            else if (i == 3)
            {
                zts = "已办结";
            }
            else if (i == 4)
            {
                zts = "直办";
            }
            return zts;
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            return "";
        }

    }
}